# 统一错误处理
from flask import Blueprint, jsonify
from marshmallow import ValidationError

error = Blueprint('error', __name__)


# 捕获ValidationError异常并返回json给客户端
@error.app_errorhandler(ValidationError)
def handle_valid_error(e):
    result_dict = {'status_code': 400, 'error_message': e.messages}
    return jsonify(result_dict)
